from itertools import permutations as per
zu=input("请输入组名(不知道填A):")
for i in open("jgb"+zu+".txt"):
    exec(i)
print("1.战痕累累 2.破损不堪 3.久经沙场 4.略有磨损 5.崭新出厂")
k1=input("请输入你想计算的两种磨损等级(例:3 4):").split(" ")
last=1
with open("jgb"+zu+".txt","r") as f:
    last=int(list(f.readlines()[-1])[1])
jishu=[]
for i in range(1,last+1):
    dq="A"+str(i)
    shu=input("请输入"+eval(dq)[0]+"的数量:")
    for i in range(int(shu)):
        jishu.append(dq)
#print(jishu)#枪械数量
l2=[]
l3=[]
l1=input("需要的两种磨损的数量(例:4+6):").split("+")
for i in range(int(l1[0])):
    l2.append(k1[0])
for i in range(int(l1[1])):
    l2.append(k1[1])
for i in per(l2,len(l2)):
    if list(i) in l3:
        continue
    l3.append(list(i))
zx=99999
io=1
for j in l3:
    dq=0
    for i in jishu:
        for ij in range(10):
            dq+=float(eval(jishu[ij])[int(j[ij])])
        if(zx>dq):
            zx=dq
            pl=j
print("最低价排列:"+str(pl))
print("排列总价:"+str(zx))
